package com.itheima.controller;

import com.itheima.R;
import com.itheima.pojo.CmsSubject;
import com.itheima.service.CmsSubjectService;
import com.itheima.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 袁鹏
 * @date 2022-10-14-8:32
 */
@RestController
@RequestMapping("/subject")
public class CmsSubjectController {

    @Autowired
    private CmsSubjectService cmsSubjectService;

    /**
     * 根据专题名称分页获取商品专题
     */
    @GetMapping("/list")
    public R list(String keyword, Integer pageNum, Integer pageSize){
        PageResult<CmsSubject> pageInfo = cmsSubjectService.page(keyword, pageNum, pageSize);
        return R.success(pageInfo);
    }


    /**
     * 获取全部商品专题
     */
    @GetMapping("/listAll")
    public R listAll(){
        List<CmsSubject> subjectList = cmsSubjectService.listAll();
        return R.success(subjectList);
    }
}
